<template>
	<view class="content" :style="{minHeight:height+1+'px'}">
		<view v-if="list.length<1" style="color: #999999;text-align: center;line-height: 100upx">
			您暂未缴纳诚意金</view>
		<view class="wrap" :style="{marginTop:index?'20px':0}" v-for="item,index in list" @click="goDetails">
			<view class="top-wrap">
				<text>存缴单号20190233150022544</text>
				<text>2019.06.24 12:32:34</text>
			</view>
			<view class="cunjiao">
				缴纳金额(元)
			</view>
			<view class="gold">
				200000
			</view>
			<view class="msg">
				认缴楼盘：九五公馆-四川九武房地产有限公司
			</view>
			<view class="msg">
				缴存账户：工商银行6214 **** 9795(于平)
			</view>
			<view class="msg">
				冻结状态：已解冻，诚意金已返回缴存账户
			</view>
			<view class="msg">
				解冻时间：2019.06.01 11:23:34
			</view>
		</view>
		<button :loading="loading==1" size="mini" class="load-but">
			{{loading==-1?'':loading==1?'正在加载更多':''}}
		</button>
	</view>
</template>

<script>
	import API from '../../common/api.js';
	export default {
		components: {
		},
		data() {
			return {
				height: uni.getSystemInfoSync().windowHeight,
				list:[],
				loading:0,
				page:0,
				userData:uni.getStorageSync('data')?JSON.parse(uni.getStorageSync('data')):null,
			}
		},
		onLoad() {
			// this.getData(true)
		},
		onPullDownRefresh(){
			this.getData(true)
		},
		onReachBottom(){
			if([-1,-2].indexOf(this.loading)<0){
				this.getData()
			}
		},
		methods: {
			clikeGetData() {
				if (this.loading == -2) {
					this.getData()
				}
			},
			async getData(flag) {
				if (flag) {
					uni.showLoading()
				} else {
					this.loading = 1
				}
				let json = await API.bankHolds({
					limit: 10,
					page: flag ? 0 : this.page,
					userId: this.userData.user.id
				});
				if (json.status == 200) {
					if (flag) {
						this.list = json.data
						this.page = 0
						uni.stopPullDownRefresh()
						uni.hideLoading()
					} else {
						this.page++
						this.list = this.list.concat(json.data)
					}
					if (json.data.length < 10) {
						this.loading = -1
					} else {
						this.loading = 0
					}
				} else {
					if (flag) {
						uni.showModal({
							title: '提示',
							content: '刷新失败，请重试',
							showCancel: false,
						});
						uni.stopPullDownRefresh()
						uni.hideLoading()
					} else {
						uni.showModal({
							title: '提示',
							content: '加载失败，请重试',
							showCancel: false,
						});
						this.loading = -2
					}
				}
			},
		}
	}
</script>

<style scoped>
	button:after {
		border-width: 0;
	}
	.content {
		background: #F3F3F3;
	}
	.wrap{
		padding:20upx 3%;
		background: white;
	}
	.top-wrap{
		color: rgba(181, 181, 181, 1);
		font-size: 24upx;
		display: flex;
		width: 100%;
		padding-bottom: 10upx;
		justify-content: space-between;
		font-family: PingFangSC-regular;
		border-bottom:1px solid #EAEAEA;
	}
	.cunjiao{
		color: rgba(34, 34, 34, 1);
		margin-top: 40upx;
		margin-bottom: 20upx;
		font-size: 26upx;
		font-family: PingFangSC-regular;
	}
	.gold{
		color: rgba(34, 34, 34, 1);
		font-size:56upx;
		margin-bottom: 40upx
	}
	.msg{
		color: rgba(34, 34, 34, 1);
		font-size: 26upx;
		line-height: 40upx;
		font-family: PingFangSC-regular;
	}
	.name{
		color: rgba(0, 0, 0, 1);
		font-size: 36upx;
		font-family: PingFangSC-regular;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	.address{
		color: rgba(155, 155, 155, 1);
		font-size: 28upx;
		font-family: PingFangSC-regular;
	}
	.load-but{
		width: 100%;
		border:0px solid white;
		background:#F3F3F3;
	}
</style>
